package net.yambal.android.air.roulette
{
	import flash.display.Sprite;
	
	public class FanSprite extends Sprite
	{
		private var _r:Number = 100;
		
		private var _line_width:int = 1;
		private var _line_color:uint = 0x000000;
		private var _fill_color:uint = 0x666666;
		private var _fill_alpha:Number = 1;
		
		private var _degree:Number = -1;
		
		public function FanSprite()
		{
			super();
		}
		
		public function setStyle(line_width:int, line_color:uint, fill_color:uint, fill_alpha:Number):void{
			_line_color = line_color;
			_line_width = line_width;
			_fill_color = fill_color;
			_fill_alpha = fill_alpha;
			
			draw();
		}

		public function set degree(degree:Number):void{
			_degree = degree;
			draw();
		}
		
		private function draw():void{
			if(_degree <= 0){
				return;
			}
			
			var radian:Number = Math.PI / 180 * (_degree / 2);
			var sin:Number = Math.sin(radian);
			var cos:Number = Math.cos(radian);
			
			graphics.clear();
			
			graphics.beginFill(_fill_color, _fill_alpha);
			graphics.lineStyle(_line_width, _line_color);
			graphics.moveTo(0, 0);
			graphics.lineTo(cos * _r, sin * -_r);
			graphics.curveTo(cos * _r + (_r - cos * _r) * 2, 0, cos * _r, sin * _r);
			graphics.endFill();
		}
	}
}